﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;

namespace KPIS.GERP.GHRMS.MODEL
{
    [Serializable]
    public class EmployeeInfo : RecordInfo
    {
        private int emp_seq1;
        private PersonInfo personInfo;
        private AddressInfo address;
        private EmployeeTypeInfo emp_type_seq;
        private ClassInfo class_seq;
        private Nullable<int> salary_level_seq;
        private Nullable<double> salary;
        private PositionInfo pos_seq;
        private JobSiteInfo working_job_site_seq;
        private Nullable<DateTime> date_admitted;
        private Nullable<DateTime> date_work_start;
        private Nullable<DateTime> date_quit;
        private EmployeeStatusInfo emp_status_seq;
        private Nullable<int> emp_sec_seq;
        private Nullable<DateTime> probation_date_end;
        private Nullable<DateTime> date_latest_pos;
        private Nullable<DateTime> date_latest_class;
        private Nullable<DateTime> date_latest_working_job_site;
        private Nullable<DateTime> retire_date;
        private Nullable<int> retire_age;
        private string admitted_duration;
        private bool fund_member;
        private Nullable<int> retire_bg_year;
        private Nullable<int> retire_bg_year_to;
        private string code_scan;
        private string imageUnique;

        public EmployeeInfo()
        {
        }
        public EmployeeInfo(int Sequence)
        {
            this.Sequence = Sequence;
        }
        public EmployeeInfo(int Sequence, PersonInfo Person, EmployeeTypeInfo EmployeeType
            , ClassInfo Class, Nullable<int> SalaryLevel, Nullable<double> Salary, PositionInfo Position
            , JobSiteInfo WorkingJobSite, Nullable<DateTime> AdmittedDate, Nullable<DateTime> WorkStartDate
            , Nullable<DateTime> QuitDate, EmployeeStatusInfo Status, Nullable<int> Section
            , Nullable<DateTime> ProbationEndDate, Nullable<DateTime> LatestPositionDate
            , Nullable<DateTime> LatestClassDate, Nullable<DateTime> LatestWorkingJobSiteDate, bool FundMember
            , string RecordStatus, Nullable<int> CreatedBy, Nullable<int> UpdatedBy, string ImageUnique = "")
        {
            this.Sequence = Sequence;
            this.Person = Person;
            this.EmployeeType = EmployeeType;
            this.Class = Class;
            this.SalaryLevel = SalaryLevel;
            this.Salary = Salary;
            this.Position = Position;
            this.WorkingJobSite = WorkingJobSite;
            this.AdmittedDate = AdmittedDate;
            this.WorkStartDate = WorkStartDate;
            this.QuitDate = QuitDate;
            this.Status = Status;
            this.Section = Section;
            this.ProbationEndDate = ProbationEndDate;
            this.LatestPositionDate = LatestPositionDate;
            this.LatestClassDate = LatestClassDate;
            this.LatestWorkingJobSiteDate = LatestWorkingJobSiteDate;
            this.FundMember = FundMember;
            this.RecordStatus = RecordStatus;
            this.CreatedBy = CreatedBy;
            this.UpdatedBy = UpdatedBy;
            this.ImageUnique = ImageUnique;
        }
        public int Sequence
        {
            get
            {
                return emp_seq1;
            }
            set
            {
                emp_seq1 = value;
            }
        }
        public PersonInfo Person
        {
            get { return personInfo; }
            set { personInfo = value; }
        }
        public AddressInfo Address
        {
            get { return address; }
            set { address = value; }
        }
        public EmployeeTypeInfo EmployeeType
        {
            get
            {
                return emp_type_seq;
            }
            set
            {
                emp_type_seq = value;
            }
        }
        public ClassInfo Class
        {
            get
            {
                return class_seq;
            }
            set
            {
                class_seq = value;
            }
        }
        public Nullable<int> SalaryLevel
        {
            get
            {
                return salary_level_seq;
            }
            set
            {
                salary_level_seq = value;
            }
        }
        public Nullable<double> Salary
        {
            get
            {
                return salary;
            }
            set
            {
                salary = value;
            }
        }
        public PositionInfo Position
        {
            get
            {
                return pos_seq;
            }
            set
            {
                pos_seq = value;
            }
        }
        public JobSiteInfo WorkingJobSite
        {
            get
            {
                return working_job_site_seq;
            }
            set
            {
                working_job_site_seq = value;
            }
        }
        public EmployeeStatusInfo Status
        {
            get
            {
                return emp_status_seq;
            }
            set
            {
                emp_status_seq = value;
            }
        }
        public Nullable<int> Section
        {
            get
            {
                return emp_sec_seq;
            }
            set
            {
                emp_sec_seq = value;
            }
        }
        public bool FundMember
        {
            get
            {
                return fund_member;
            }
            set
            {
                fund_member = value;
            }
        }        
        public Nullable<DateTime> AdmittedDate
        {
            get
            {
                return date_admitted;
            }
            set
            {
                date_admitted = value;
            }
        }
        public Nullable<DateTime> WorkStartDate
        {
            get
            {
                return date_work_start;
            }
            set
            {
                date_work_start = value;
            }
        }
        public Nullable<DateTime> QuitDate
        {
            get
            {
                return date_quit;
            }
            set
            {
                date_quit = value;
            }
        }
        public Nullable<DateTime> ProbationEndDate
        {
            get
            {
                return probation_date_end;
            }
            set
            {
                probation_date_end = value;
            }
        }
        public Nullable<DateTime> LatestPositionDate
        {
            get
            {
                return date_latest_pos;
            }
            set
            {
                date_latest_pos = value;
            }
        }
        public Nullable<DateTime> LatestClassDate
        {
            get
            {
                return date_latest_class;
            }
            set
            {
                date_latest_class = value;
            }
        }
        public Nullable<DateTime> LatestWorkingJobSiteDate
        {
            get
            {
                return date_latest_working_job_site;
            }
            set
            {
                date_latest_working_job_site = value;
            }
        }
        public string AdmittedDuration
         {
            get
            {
                return admitted_duration;
            }
            set
            {
                admitted_duration = value;
            }
        }
        public Nullable<DateTime> RetireDate
        {
            get
            {
                return retire_date;
            }
            set
            {
                retire_date = value;
            }
        }
        public Nullable<int> RetireYear
        {
            get
            {
                if (!retire_date.HasValue)
                {
                    return null;
                }
                else
                {
                    int thaiYear = new ThaiBuddhistCalendar().GetYear(retire_date.Value);
                    return thaiYear;
                }
            }
        }
        public Nullable<int> RetireAge
        {
            get
            {
                return retire_age;
            }
            set
            {
                retire_age = value;
            }
        }
        public Nullable<int> RetireBudgetYear
        {
            get
            {
                return retire_bg_year;
            }
            set
            {
                retire_bg_year = value;
            }
        }
        public Nullable<int> RetireBudgetYearEnd
        {
            get
            {
                return retire_bg_year_to;
            }
            set
            {
                retire_bg_year_to = value;
            }
        }
        public string CodeScan
        {
            get
            {
                return code_scan;
            }
            set
            {
                code_scan = value;
            }
        }
        public string ImageUnique
        {
            get
            {
                return imageUnique;
            }
            set
            {
                imageUnique = value;
            }
        }
        public string RefNo
        {
            get { return Position != null ? Position.RefNo: ""; }
        }
        public int? PosTypeSeq
        {
            get { return Position != null ? Position.PosTypeSeq : null; }
        }
        public override string ToString()
        {
            return (Position != null ? Position.RefNo + " " + Position.Name + " - " : "") + (Person != null ? Person.FullName : "");
        }
        public string Full
        {
            get { return ToString(); }
        }
    }
}
